<template>
  <el-tree
    :loading="load"
    :data="dataKey"
    show-checkbox
    node-key="code"
    :props="defaultProps"
    default-expand-all
    :expand-on-click-node="false"
    :default-checked-keys="treeArr"
    @check="currentChecked"
  />
</template>
<script>
export default {
  props: {
    dataKey: {
      type: Array
    },
    load: {
      type: Boolean,
      default: false
    },
    treeArr: {
      type: Array
    }
  },
  data() {
    return {
      defaultProps: {
        children: 'children',
        label: 'name'
      }
    }
  },
  methods: {
    // 点击tree时
    currentChecked(nodeObj, SelectedObj) {
      this.$emit('getKeyData', SelectedObj.checkedKeys)
    }
  }
}
</script>
<style lang="scss" scoped>
::v-deep .el-tree-node.is-expanded > .el-tree-node__children {
  .el-tree-node__children {
    display: flex;
  }
}
::v-deep .el-tree-node__label{
  color: #000000;
  font-weight: 400;
}
::v-deep .el-tree-node__content{
  margin-bottom: 5px;
  width:180px;
}

::v-deep .el-tree-node.is-expanded > .el-tree-node__children .el-tree-node__children{
  flex-wrap: wrap;
}
</style>
